cmake_minimum_required(VERSION 2.8)
project(liblzma)
file(GLOB_RECURSE lib_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.c)
file(GLOB_RECURSE lib_hdrs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} api/lzma/*.h)
set(CMAKE_DEBUG_POSTFIX "D")
include_directories(${CMAKE_CURRENT_SOURCE_DIR} api check common common0 delta lz lzma rangecoder simple)
add_definitions(/DHAVE_CONFIG_H)
if(MSVC)
  list(APPEND lib_srcs ${PROJECT_NAME}.def liblzma_w32res.rc)
endif()
add_library(${PROJECT_NAME} SHARED ${lib_srcs})
install(FILES api/lzma.h DESTINATION include)
install(FILES ${lib_hdrs} DESTINATION include/lzma)
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
install(EXPORT ${PROJECT_NAME}-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}-config.cmake)

if(BUILD_STATIC)
  add_library(${PROJECT_NAME}S STATIC ${lib_srcs})
  install(TARGETS ${PROJECT_NAME}S EXPORT ${PROJECT_NAME}S-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
  install(EXPORT ${PROJECT_NAME}S-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}S-config.cmake)
endif()
